﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="System_Dict.aspx.cs" Inherits="KPI_SYSTEM.DictPage.System_Dict" %>
<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <style>
        
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" AutoSizePanelID="RegionPanel1" />
        <f:RegionPanel ID="RegionPanel1" IsFluid="true" CssClass="blockpanel" ShowBorder="false" runat="server" Margin="20px">
            <Regions>
                <f:Region ID="Region1" ShowBorder="false" ShowHeader="false" RegionPosition="Left" BodyPadding="0 5 0 0"
                    Width="220px" Layout="Fit" runat="server">
                    <Items>
                        <f:Grid ID="GridLeft" ShowBorder="true" ShowHeader="false"  runat="server" 
                            DataKeyNames="REC_ID" EnableMultiSelect="false" EnableRowSelectEvent="true" OnRowSelect="GridLeft_RowSelect" 
                            ShowGridHeader="true">
                            <Toolbars>
                                <f:Toolbar ID="Toolbar3" Position="Top" runat="server">
                                    <Items>
                                        <f:Button ID="Button1" Text="新增" Icon="Add" EnablePostBack="false" runat="server">
                                            <Listeners>
                                                <f:Listener Event="click" Handler="onLeftNewButtonClick" />
                                            </Listeners>
                                        </f:Button>
                                        <f:Button ID="Button2" Text="删除" Icon="Delete" ConfirmText="确定删除当前数据？" OnClick="btnLeftDelete_Click"
                                            runat="server">
                                        </f:Button>
                                    </Items>
                                </f:Toolbar>
                            </Toolbars>
                            <Columns>
                                <f:RenderField Width="200px" ColumnID="DICT_NAME" DataField="DICT_NAME"
                                    HeaderText="字典类别">
                                </f:RenderField>
                            </Columns>
                        </f:Grid>
                    </Items>
                </f:Region>
                <f:Region ID="Region2" ShowBorder="false" ShowHeader="false" Position="Center"
                    Layout="VBox" BoxConfigAlign="Stretch" runat="server">
                    <Items>
                       
                        <f:Grid ID="GridRight" IsFluid="true" CssClass="blockpanel" ShowBorder="true" ShowHeader="true" EnableCollapse="false"
                            runat="server" DataKeyNames="REC_ID" AllowCellEditing="false"   EnableRowSelectEvent="true" PageSize="15" AllowPaging="true" IsDatabasePaging="false"
                            DataIDField="REC_ID" Title="字典项目" OnRowCommand="GridRight_RowCommand"  OnPreRowDataBound="GridRight_PreRowDataBound">
                            <Toolbars>
                                <f:Toolbar ID="Toolbar2" Position="Top" runat="server">
                                    <Items>
                                        <f:Button ID="btnNew" Text="新增" Icon="Add" EnablePostBack="false" runat="server">
                                            <Listeners>
                                                <f:Listener Event="click" Handler="onRightNewButtonClick" />
                                            </Listeners>
                                        </f:Button>
                                        <f:Button ID="Delete" Text="删除" Icon="Delete" ConfirmText="确定删除当前数据？" OnClick="btnRightDelete_Click"
                                            runat="server">
                                        </f:Button>
                                    </Items>
                                </f:Toolbar>
                            </Toolbars>
                            <Columns>
                                <f:TemplateField Width="60px">
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>
                                    </ItemTemplate>
                                </f:TemplateField>
                                <f:RenderField Width="180px" ColumnID="DICT_NAME" DataField="DICT_NAME" 
                                    HeaderText="项目名称">
                                </f:RenderField>
                                <f:RenderField Width="180px" ColumnID="DICT_VALUE" DataField="DICT_VALUE"
                                    HeaderText="项目内容">
                                </f:RenderField>
                                <f:RenderField Width="180px" ColumnID="DICT_REMARK" DataField="DICT_REMARK"
                                    HeaderText="项目说明">
                                </f:RenderField>
                                <f:LinkButtonField ColumnID="Edit" Width="50px" EnablePostBack="false" Icon="Pencil" />
                                <f:LinkButtonField Width="50px" ConfirmText="删除选中行？" ConfirmTarget="Top" CommandName="Delete" Icon="Delete" />
                            </Columns>
                        </f:Grid>
                    </Items>
                </f:Region>
                
            </Regions>
        </f:RegionPanel>
        <f:Window ID="WindowsLeft" Title="弹出窗体" Hidden="true" EnableIFrame="false"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="400px">
            <Items>
                <f:SimpleForm ID="SimpleFormLeft" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:HiddenField ID="hfFormIDLeft" runat="server"></f:HiddenField>
                        <f:TextBox ID="txtFormDICT_NAME" ShowRedStar="true" Label="类别名称" Required="true" runat="server">
                        </f:TextBox> 
                    </Items>
                    <Toolbars>
                        <f:Toolbar ID="Toolbar1" Position="Bottom" ToolbarAlign="Right" runat="server">
                            <Items>
                                <f:Button ID="btnLeftSave"
                                    Icon="SystemSave" runat="server" Text="保存数据" ValidateForms="SimpleFormLeft" OnClick="btnLeftSave_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                </f:SimpleForm>
            </Items>
        </f:Window>
         <f:Window ID="WindowsRight" Title="弹出窗体" Hidden="true" EnableIFrame="false"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="400px">
            <Items>
                <f:SimpleForm ID="SimpleFormRight" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:HiddenField ID="hfFormIDRight" runat="server"></f:HiddenField>
                        <f:TextBox ID="txtRightDICT_NAME" ShowRedStar="true" Required="true"  Label="项目名称" runat="server">
                        </f:TextBox>
                        <f:TextBox ID="txtRightDICT_VALUE" ShowRedStar="true" Required="true" Label="项目内容"  runat="server">
                        </f:TextBox> 
                        <f:TextBox ID="txtRightDICT_REMARK" Label="项目说明"  runat="server">
                        </f:TextBox>   
                       
                    </Items>
                    <Toolbars>
                        <f:Toolbar ID="Toolbar4" Position="Bottom" ToolbarAlign="Right" runat="server">
                            <Items>
                                <f:Button ID="btnRightSave"
                                    Icon="SystemSave" runat="server" Text="保存数据" ValidateForms="SimpleFormRight" OnClick="btnRightSave_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                </f:SimpleForm>
            </Items>
        </f:Window>
        <br />
        <br />
        <br />
    </form>
    <script src="../res/js/ApprovalButton.js"></script>
     <script>
        //左侧列表添加事件
        var windowLeftClientID = '<%= WindowsLeft.ClientID %>';
        var btnLeftSaveClientID = '<%= btnLeftSave.ClientID %>';
        var formLeftClientID = '<%= SimpleFormLeft.ClientID %>';
        var hfFormIDLeftClientID = '<%= hfFormIDLeft.ClientID %>';
        function onLeftNewButtonClick(event) {
            // 重置表单字段
            F(formLeftClientID).reset();
            F(hfFormIDLeftClientID).setValue(null);
            // 弹出窗体
            F(windowLeftClientID).show();
            F(windowLeftClientID).setTitle('新增数据');
         }
         //右上侧列表添加事件
         var rightgridClientID = '<%= GridRight.ClientID %>';
        var windowRightClientID = '<%= WindowsRight.ClientID %>';
        var btnRightSaveClientID = '<%= btnRightSave.ClientID %>';
        var formRightClientID = '<%= SimpleFormRight.ClientID %>';
         var hfFormIDRightClientID = '<%= hfFormIDRight.ClientID %>';

         var txtRightDICT_NAMEClientID  = '<%= txtRightDICT_NAME.ClientID %>';
         var txtRightDICT_VALUEClientID = '<%= txtRightDICT_VALUE.ClientID %>';
         var txtRightDICT_REMARKClientID = '<%= txtRightDICT_REMARK.ClientID %>';

        function onRightNewButtonClick(event) {
            // 重置表单字段
            F(formRightClientID).reset();
            F(hfFormIDRightClientID).setValue(null);
            // 弹出窗体
            F(windowRightClientID).show();
            F(windowRightClientID).setTitle('新增数据');
         }
         function onEditButtonClick(event) {
            showEditWindow();
        }

         function showEditWindow(rowId) {
             var grid = F(rightgridClientID);
             
          

            // 如果传入参数为空，则获取当前选中行
            if (!rowId) {
                var selectedRowIds = grid.getSelectedRows();
                if (!selectedRowIds.length) {
                    F.alert('请至少选择一项！');
                    return;
                }

                rowId = selectedRowIds[0];
            }

            
            F(windowRightClientID).setTitle('编辑数据');

            // 当前行数据
            var rowValue = grid.getRowValue(rowId);

            // 使用当前行数据填充表单字段
            F(hfFormIDRightClientID).setValue(rowId);
            F(txtRightDICT_NAMEClientID).setValue(rowValue['DICT_NAME']);
            F(txtRightDICT_VALUEClientID).setValue(rowValue['DICT_VALUE']);
             F(txtRightDICT_REMARKClientID).setValue(rowValue['DICT_REMARK']);
            // 弹出新增窗体
            F(windowRightClientID).show();
        }
    </script>
 </body>
</html>
